function getUrlParam(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if (r != null) return unescape(r[2]); return null;
}

function fmt(str,type){
	type = str == '' | str == null ? '' : type;
	var datetime = new Date(str);
	var year = datetime.getFullYear();
	var month = (datetime.getMonth() + 1).toString();
	if(month.length<2){month='0'+month}
	var day = datetime.getDate().toString();
	if(day.length<2){day='0'+day}
	var hour = datetime.getHours();
	var ampm;
	if ( hour < 12 ){
		ampm = '上午';
	} else {
		ampm = '下午';
		hour -= 12;
	}
	hour = hour.toString();
	if(hour.length<2){hour='0'+hour}
	var min = datetime.getMinutes().toString();
	if(min.length<2){min='0'+min}
	var sec = datetime.getSeconds().toString();
	if(sec.length<2){sec='0'+sec}

	var nowTime = new Date();
	var ago = nowTime - datetime;
	var agoSec = ago / 1000;
	var agoMin = agoSec / 60;
	var agoHour = agoMin / 60;
	var agoDay = agoHour / 24;
	var agoWeek = agoDay / 7;
	var agoMonth = agoDay / 30;
	var agoYear = agoDay / 365;

	switch (type){
		case 'date':
			return year + '-' + month + '-' + day;
			break;
		case 'datetime':
			return year + '-' + month + '-' + day + ' ' + ampm + ' ' + hour + ':' + min + ':' + sec;
			break;
		case 'pdate':
			return year + '-' + month + '-' + day + 'T' + hour + ':' + min + ':' + sec;
			break;
		case 'pdate1':
			return year + '-' + month + '-' + day + 'T' + '00:00:00';
			break;
		case 'pdate2':
			return year + '-' + month + '-' + day + 'T' + '23:59:59';
			break;
		case 'ago':
			var result;
			if (agoYear >= 1) {
				result = year + '-' + month + '-' + day;
			} else if (agoMonth >= 1) {
				result = parseInt(agoMonth) + "月 前";
			} else if (agoWeek >= 1) {
				result = parseInt(agoWeek) + "周 前";
			} else if (agoDay >= 1) {
				result = parseInt(agoDay) + "天 前";
			} else if (agoHour >= 1) {
				result = parseInt(agoHour) + "小时 前";
			} else if (agoMin >= 1) {
				result = parseInt(agoMin) + "分钟 前";
			} else {
				result = "刚刚";
			}
			return result;
			break;
		default:
			if ( typeof(str) == "undefined" || str == null || str == "null" || str.length == 0) {
				return '';
			} else {
				return str;
			}
	}
};

function loadShow(){
	$('#loading').show();
	$('body').css('overflow','hidden');
}

function loadHide(){
	$('#loading').hide();
	$('body').css('overflow','auto');
}

$(function(){
	$('#wrap').on('click', '.detail > .title:not(".nomore")', function(){
		$(this).toggleClass('off').next().toggleClass('displaynone');
	});

	$('#wrap').on('click', '.detail > .title input', function(e){
		e.stopPropagation();
	});

	$('#wrap,#footer').on('click', '.btnArea button.close', function(){
		history.go(-1);
	});
});
